/*
 * SystemFactory.h
 *
 *  Created on: 21.05.2011
 *      Author: sili
 */

#ifndef SYSTEMFACTORY_H_
#define SYSTEMFACTORY_H_

#include "AALItem.h"
#include "AALSystemItem.h"
//#include "AALLocatorItem.h"
//#include "AALSensorItem.h"
//#include "AALActorItem.h"

#include "Controller.h"

class SystemFactory : public ActionListener{
private:
	Controller * controller;
	cMutex mutex;

	AALItem * system; 				// The system. Knows which flats are present, which flat uses which AALIcon and so on
	string configDir;				// The directory where the configuration files will be stored
	string systemXmlFile;			// The system.xml file inside the configuration directory
	string messageXmlFile;

	void deSerializeSystemFile();
	void serializeSystem();

public:
	SystemFactory(Controller * _controller, const char * _configDir);
	virtual ~SystemFactory();

	bool updateAALItem(AALItem * _newAALItem, int _oldId, int _parentId, string * _response);
	bool deleteAALItem(int _id, string * _response);

	/**
	 * OVERWRITE
	 * I'm an ActionListener
	 */
	void doAction(AALAction * _action);
	void doMainSavedAction();

	const char * getConfigDir();

	AALItem * getSystem();
	string * importFlatSvg(const char * _flatSvgFile);
	Visualizer * visualizer;
};

#endif /* SYSTEMFACTORY_H_ */
